/*-------------------------------------------------------------------------
   Copyright (C) 2010 One Laptop per Child

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

   In other words, you are welcome to use, share and improve this program.
   You are forbidden to forbid anyone else to use, share and improve
   what you give them.   Help stamp out software-hoarding!

   As a special exception, you may use this file as part of a free software
   library for the XO of the One Laptop per Child project without restriction.
   Specifically, if other files instantiate
   templates or use macros or inline functions from this file, or you compile
   this file and link it with other files to produce an executable, this
   file does not by itself cause the resulting executable to be covered by
   the GNU General Public License.  This exception does not however
   invalidate any other reasons why the executable file might be covered by
   the GNU General Public License.
-------------------------------------------------------------------------*/
#ifndef PS2_H
#define PS2_H

#ifndef NO_PS2

#include "cc_compat.h"

extern data unsigned char ignore_ps2_data;
extern unsigned char xdata KB_error_flags;

#define DEST_KEYBOARD	0x02
#define DEST_TOUCHPAD	0x08

void intsrv_ps2(void) EXTERN_INTERRUPT(10);

void ps2_module_init(void);
void ps2_set_interrupt_ignore(void);
void ps2_clear_interrupt_ignore(void);
void ps2_process(void);
void ps2_init(void);
void ps2_tp_queue_clear(void);
void ps2_kb_queue_clear(void);
void ps2_tx_queue_clear(void);
void ps2_start(void);

int ps2_tp_queue_get(void);
int ps2_kb_queue_get(void);

int ps2_tp_queue_add(unsigned char val);
int ps2_kb_queue_add(unsigned char val);
int ps2_tx_queue_get(void);

unsigned char ps2_tp_queue_size(void);
unsigned char ps2_kb_queue_size(void);
unsigned char ps2_tx_queue_size(void);
unsigned char ps2_tp_queue_full(void);

int ps2_tx_queue_add(unsigned char dest, unsigned char val);

void ps2_cmd_keyboard_cmd(void);
void ps2_cmd_touchpad_cmd(void);

#endif  // NO_PS2
#endif  // PS2_H
